package com.property.inf;
 


public abstract class BaseAbstractSet<E> extends BaseAbstractCollection<E> implements BaseSet<E> {
	
	protected BaseAbstractSet(){
		
	} 
 
	public boolean equals(Object o){
		if(o==this)return true;
		if(!(o instanceof BaseSet))return false;
		BaseCollection c=(BaseCollection) o;
		
		if(c.size()!=size()) return false;
		try{
			return containsAll(c);
		}catch(ClassCastException unused){
			return false;			
		}catch(NullPointerException unused){
			return false;
		} 
	}
	
	public boolean removeAll(BaseCollection<?> c){
		boolean modified=false;
		if(size()>c.size()){
			for(BaseIterator<?> i=c.iterator();i.hasNext();){
				modified |=remove(i.next());				
			}
		}else{
			for(BaseIterator<?> i=iterator();i.hasNext();)
			{
				i.remove();
				modified =true;
			}
		}
		
		return modified;
		
	}
 
	public  int hashCode(){
		int h=0;
		BaseIterator<E> i=iterator();
		while(i.hasNext()){
			E obj=i.next();
			if(obj!=null){
				h+=obj.hashCode();
			}
		}
		return h;		
	}

}
